package multiplayerShooter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class PlayerInputHandler implements KeyListener {
	private Player player;	
	private int upKey;
	private int downKey;
	private int leftKey;
	private int rightKey;
	private int shootKey;
	
	public PlayerInputHandler(Player player){
	this.player=player;
	}
	public void setKeys(int up, int down, int left, int right, int shoot) {
		upKey = up;
		downKey = down;
		leftKey = left;
		rightKey = right;
		shootKey = shoot;
		
	}

	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode()== leftKey)
			player.startMoveingLeft();
		else if(e.getKeyCode()== rightKey)
			player.startMovingRight();
		else if(e.getKeyCode()== upKey)
			player.startJumping();
		else if(e.getKeyCode()== downKey)
			player.down();
		else if(e.getKeyCode()== shootKey)
			player.startShooting();
			
	}
		
	

	public void keyReleased(KeyEvent e) {
		if(e.getKeyCode()== leftKey)
			player.stopMovingLeft();
		else if(e.getKeyCode()== rightKey)
			player.stopMovingRight();
		else if(e.getKeyCode()== upKey)
			player.stopJumping();
		else if(e.getKeyCode()== shootKey)
			player.stopShooting();
		
	}

	public void keyTyped(KeyEvent arg0) {/*Do Nothing*/}

}
